package ru.susu.algebra.partition.operation;

import java.util.Arrays;

import ru.susu.algebra.operation.IOperation;
import ru.susu.algebra.partition.Partition;

/**
 * @author akargapolov
 * @since: 11.03.2010
 */
public class Partition2VertexOperation implements IOperation<Integer[]>
{
	public static IOperation<Integer[]> INSTANCE = new  Partition2VertexOperation();

	@Override
	public Integer[] performOperation(Object... sources)
	{
		Partition p = (Partition)sources[0];
		Integer[] result = new Integer[p.getPresentedNumber()];
		Arrays.fill(result, 0);
		for (Integer value : p.getArrayRepresentation())
			result[value - 1]++;
		return result;
	}

}
